#include "iostream"

using namespace std;

void run() {
    string A, Q;
    int B, R;
    cin >> A >> B;
//    A = "123456789050987654321";
//    B = 7;

    Q = "";
    R = 0;

    for (int i = 0; i < A.length(); i++) {
        int tmp = R * 10 + (A[i] - '0');
        Q += char(tmp / B + '0');
        R = tmp % B;
    }

    if (Q[0] == '0') {
        Q = Q.substr(1, A.length());
    }
    if (Q == "") {
        Q = "0";
    }

    cout << Q << " " << R << endl;
}

int main() {
    run();
    return 0;
}
